﻿ //trace ("#included: as/time_G.as")
var alarmFlg : Boolean = true ;
var mydate = new Date ();
var ngay = (mydate.getDate () < 10) ? "0" + mydate.getDate () : mydate.getDate ();
var thang = ((mydate.getMonth () + 1) < 10) ? "0" + (mydate.getMonth () + 1) : mydate.getMonth () + 1;
var nam = mydate.getFullYear ();
var giay = (mydate.getSeconds () < 10 ) ? "0" + mydate.getSeconds () : mydate.getSeconds ();
var gio = mydate.getHours ();
var gio24 = gio;
var ampm = "AM"
if (gio > 12)
{
	gio -= 12;
	ampm = "PM";
}
if (gio == 12)
{
	ampm = "PM"
};
gio = (gio < 10) ? "0" + gio : gio;
var phut = (mydate.getMinutes () < 10) ? "0" + mydate.getMinutes () : mydate.getMinutes ();
strTime = gio + ":" + phut + ":" + giay + " " + ampm;
strDate = ngay + "-" + thang + "-" + nam;
//strDate = nam + thang + ngay;
//Kiem tra thoi gian dat Motion Dectect
var startTimeArr : Array = _root.CFG.alarmStartTime.split (":");
var startH = startTimeArr [0];
var startM = startTimeArr [1];
var stopTimeArr : Array = _root.CFG.alarmStopTime.split (":");
var stopH = stopTimeArr [0];
var stopM = stopTimeArr [1];
var startP = int(startH) * 60 + int(startM)
var stopP = int(stopH) * 60 + int(stopM);
var nowP = int(gio24) * 60 + int(phut);
if (stopP > startP)
{
	trace (stopP > startP);
	if ((nowP >= startP) && (nowP < stopP))
	{
		alarmFlg = true;
		//trace ("1");
	} 
	else
	{
		alarmFlg = false;
		//trace ("2");
	}
}
else
{
	if ((nowP < startP) && (nowP >= stopP))
	{
		alarmFlg = false;
		//trace ("3");
	} 
	else
	{
		alarmFlg = true;
		//trace ("4");
	}
}
